﻿Partial Class NorthwindDataSet
    Partial Class ProductsDataTable

        Private Sub ProductsDataTable_ColumnChanging(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging

            If e.Column.ColumnName = "UnitsInStock" Then

                Dim i As Integer
                If Not (Integer.TryParse(e.ProposedValue.ToString, i)) Then
                    e.Row.SetColumnError(e.Column, "the value is not a number")
                Else
                    If Convert.ToInt16(e.ProposedValue) <= 0 Then
                        e.Row.SetColumnError(e.Column, "the value is negative")
                    Else : e.Row.SetColumnError(e.Column, "")
                    End If

                End If
            End If

        End Sub

        Private Sub ProductsDataTable_RowChanging(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles Me.RowChanging
            If e.Row.Item("UnitsInStock") < 10 And e.Row.Item(UnitsOnOrderColumn) < 100 Then

                e.Row.RowError = "The units on order are very low"
            Else
                e.Row.RowError = String.Empty


            End If
        End Sub

        Private Sub ProductsDataTable_TableNewRow(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) Handles Me.TableNewRow
            e.Row.Item(UnitPriceColumn) = 0
        End Sub
    End Class

End Class

Namespace NorthwindDataSetTableAdapters
    
    Partial Public Class ProductsTableAdapter
    End Class
End Namespace
